//1234 2341 3412 4123
#include<stdio.h>
int main()
{
	int n, i, j, a[10][10];
	scanf("%d", &n);
	for (i = 0; i < n; i++)//assignment
	{
		a[i][0] = i + 1;
		for (j = 0; j < n; j++)
		{
			a[i][j] = a[i][0] + j;
			if (a[i][j] > n)a[i][j] -= n;
		}
	}
	for (i = 0; i < n; i++)//output
	{
		for (j = 0; j < n; j++)
		{
			printf("%d", a[i][j]);
			if (j == n - 1)printf("\n");
			else printf(" ");
		}
	}
	return 0;
}